//
//  FWRoomViewController.swift
//  DBS
//
//  Created by 王方伟 on 2017/4/21.
//  Copyright © 2017年 wfw. All rights reserved.
//

import UIKit
import DCURLRouter

class FWRoomViewController: UIViewController {

    @IBOutlet weak var bgImageView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        setupBlurView()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.setNavigationBarHidden(true, animated: true)
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        navigationController?.setNavigationBarHidden(false, animated: true)
    }
}

//MARK:设置UI界面内容
extension FWRoomViewController {
    fileprivate func setupBlurView (){
        let blur = UIBlurEffect(style: .dark)
        let blurView = UIVisualEffectView(effect: blur)
        blurView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
        blurView.frame = bgImageView.bounds
        bgImageView.addSubview(blurView)
    }
}

//MARK:事件监听
extension FWRoomViewController : ProEmitterable{
    @IBAction func exitBtnClick() {
       DCURLRouter.popViewController(animated: true)
    }
    
    @IBAction func bottomMenuClick(_ sender: UIButton) {
        switch sender.tag {
            case 0:
                print("点击了聊天")
            case 1:
                print("点击了分享")
            case 2:
                DCURLRouter.push(FWGiftViewController(), animated: true)
            case 3:
                print("点击了更多")
            case 4:
                sender.isSelected = !sender.isSelected
                let point = CGPoint(x: sender.center.x, y: view.bounds.height - sender.bounds.height * 0.5)
                sender.isSelected ? startEmittering(point) : stopEmittering()
            default:
                fatalError("未处理按钮")
        }
    }
}
